package com.hqyj.shop.util;

import lombok.Data;

/**
 * 项目:shop-admin-240701
 * 描述: 统一响应类
 * 时间:2024/10/8 9:39
 * 作者:admin
 * 版本:1.0
 **/
@Data
public class ResultVo {

    //状态码
    private Integer code;
    //提示信息
    private String msg;
    //数据信息
    private Object data;


    public ResultVo(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    //成功01
    public static ResultVo success(){
        return new ResultVo(200,"success",null);
    }
    //成功02
    public static ResultVo success(String msg){
        return new ResultVo(200,msg,null);
    }
    //成功03
    public static ResultVo success(Object data){
        return new ResultVo(200,"success",data);
    }
    //成功04
    public static ResultVo success(String msg,Object data){
        return new ResultVo(200,msg,data);
    }
    //失败01
    public static ResultVo error(){
        return new ResultVo(500,"fail",null);
    }
    //失败02
    public static ResultVo error(String msg){
        return new ResultVo(500,msg,null);
    }
    //失败03
    public static ResultVo error(Object data){
        return new ResultVo(500,"fail",data);
    }
    //失败04
    public static ResultVo error(String msg,Object data){
        return new ResultVo(500,msg,data);
    }

    //token 验证失败
    public static ResultVo tokenError(String msg){

        return new ResultVo(300,msg,null);
    }


}
